package com.tianbo.controller;

import com.tianbo.common.ModelAndPage;
import com.tianbo.service.EtlmessageService;
import com.tianbo.util.dao.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created by Mr.Xu on 2017/9/14.
 */
@Controller
@RequestMapping("/messagebak")
public class ETLMessageBakController {
    @Autowired
    private EtlmessageService etlmessageService;

    @RequestMapping("/showlist")
    public ModelAndView findEtlMessage(@ModelAttribute Page page) throws Exception{
        int pagelenth=10;
        int start = 0;
        if(page.getBegin()>=0){ start = page.getBegin(); }
        if (page.getLength()>0){ pagelenth = page.getLength();}
        ModelAndView modelAndView=new ModelAndView();
        ModelAndPage modelAndPage=new ModelAndPage();
        modelAndPage=etlmessageService.findEtlMessage(start,pagelenth);
        modelAndView.addObject("modelAndPage",modelAndPage);
        modelAndView.setViewName("messagebak/list");
        return modelAndView;
    }

    @RequestMapping("list")
    public String list(){return "messagebak/list";}
}
